/*
 * @Author: 吴世扬 18368095041@163.com
 * @Date: 2024-09-19 09:39:50
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2024-10-15 17:58:12
 * @FilePath: /react18-vite-admin/src/components/ui/LoadingPage/LoadingPage.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { forwardRef, type CSSProperties, type ReactNode } from 'react';

import './LoadingPage.scoped.scss';

const LoadingPage = forwardRef<
    HTMLDivElement,
    { style?: CSSProperties; children?: ReactNode; loading?: boolean }
>(
    (
        props: {
            style?: CSSProperties;
            children?: ReactNode;
            loading?: boolean;
        },
        ref
    ) => {
        const { style, children, loading } = props;
        const isLoading = loading ?? true;
        return isLoading ? (
            <div style={style} ref={ref} className="loading-page-container">
                <div className="loader"></div>
            </div>
        ) : (
            children
        );
    }
);

export default LoadingPage;
